package com.example.demo.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

@Entity
public class Order {
    private int orderId;
    private String orderName;
    private BigDecimal summoney;
    private String owner;
    private String status;
    private Timestamp startTime;
    private Timestamp endTime;
    private String address;
    private int productId;
    private Client kh;
    private Xsjhinfo xsjh;
    private User qyr;
    private List<Product> cp;
    private Cashbackplan hkjh;
    private Cashbackrecord hkjl;
    private Invoicing kp;
    private Complain ts;
    private List<Fixreceive> wxjj;

    @Id
    @Column(name = "order_id", nullable = false)
    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    @Basic
    @Column(name = "order_name", nullable = false, length = 255)
    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    @Basic
    @Column(name = "summoney", nullable = false, precision = 2)
    public BigDecimal getSummoney() {
        return summoney;
    }

    public void setSummoney(BigDecimal summoney) {
        this.summoney = summoney;
    }

    @Basic
    @Column(name = "owner", nullable = false, length = 255)
    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    @Basic
    @Column(name = "status", nullable = false, length = 255)
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Basic
    @Column(name = "start_time", nullable = false)
    public Timestamp getStartTime() {
        return startTime;
    }

    public void setStartTime(Timestamp startTime) {
        this.startTime = startTime;
    }

    @Basic
    @Column(name = "end_time", nullable = false)
    public Timestamp getEndTime() {
        return endTime;
    }

    public void setEndTime(Timestamp endTime) {
        this.endTime = endTime;
    }

    @Basic
    @Column(name = "product_id", nullable = false)
    public int getProductId() {
        return productId;
    }

    public void setProductId(int endTime) {
        this.productId = productId;
    }

    @Basic
    @Column(name = "address", nullable = false, length = 255)
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Order order = (Order) o;
        return orderId == order.orderId &&
                Objects.equals(orderName, order.orderName) &&
                Objects.equals(summoney, order.summoney) &&
                Objects.equals(owner, order.owner) &&
                Objects.equals(status, order.status) &&
                Objects.equals(startTime, order.startTime) &&
                Objects.equals(endTime, order.endTime) &&
                Objects.equals(address, order.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderId, orderName, summoney, owner, status, startTime, endTime, address);
    }

    @ManyToOne
    @JoinColumn(name = "client_id", referencedColumnName = "client_id", nullable = false)
    public Client getKh() {
        return kh;
    }

    public void setKh(Client kh) {
        this.kh = kh;
    }

    @OneToOne
    @JoinColumn(name = "xsjhId", referencedColumnName = "xsjhId", nullable = false)
    public Xsjhinfo getXsjh() {
        return xsjh;
    }

    public void setXsjh(Xsjhinfo xsjh) {
        this.xsjh = xsjh;
    }

    @ManyToOne
    @JoinColumn(name = "uid", referencedColumnName = "uid", nullable = false)
    public User getQyr() {
        return qyr;
    }

    public void setQyr(User qyr) {
        this.qyr = qyr;
    }

    @OneToMany(mappedBy = "htdd")
    public List<Product> getCp() {
        return cp;
    }

    public void setCp(List<Product> cp) {
        this.cp = cp;
    }

    @OneToOne(mappedBy = "htdd")
    public Cashbackplan getHkjh() {
        return hkjh;
    }

    public void setHkjh(Cashbackplan hkjh) {
        this.hkjh = hkjh;
    }

    @OneToOne(mappedBy = "htdd")
    public Cashbackrecord getHkjl() {
        return hkjl;
    }

    public void setHkjl(Cashbackrecord hkjl) {
        this.hkjl = hkjl;
    }

    @OneToOne(mappedBy = "htdd")
    public Invoicing getKp() {
        return kp;
    }

    public void setKp(Invoicing kp) {
        this.kp = kp;
    }

    @OneToOne(mappedBy = "htdd")
    public Complain getTs() {
        return ts;
    }

    public void setTs(Complain ts) {
        this.ts = ts;
    }

    @OneToMany(mappedBy = "htdd")
    public List<Fixreceive> getWxjj() {
        return wxjj;
    }

    public void setWxjj(List<Fixreceive> wxjj) {
        this.wxjj = wxjj;
    }
}
